#pragma once

///////////////////////////////////////////////////////////////////////////
//																		 //
//	Author:		Michael Mozdzierz										 //
//	Date:		12/07/2014												 //
//	Purpose:	Define a sound object that plays sound in 3D space		 //
//																		 //
///////////////////////////////////////////////////////////////////////////

#include "ISoundElement.h"
#include "../EdgeMath/Vectors.h"
#include <fmod.h>
#include <fmod.hpp>

class SoundEffect3D : public ISoundElement
{
	friend class AudioManager;

	FMOD::Sound* sound = nullptr;

	FMOD::Channel* channel = nullptr;

	unsigned int flags;

	Vector3 position;

	Vector3 velocity;

	float range;

	virtual bool getIsPlaying(void) const override { return true; }

	virtual bool getIsLooped(void) const override { return isLooped; }

	virtual FMOD::Channel* getChannel(void) const override { return channel; }

	virtual FMOD::Sound* getSound(void) const override { return sound; }

	virtual void setChannel(FMOD::Channel* value) override { channel = value; }

	virtual void setSound(FMOD::Sound* value) override { sound = value; }

	virtual void setIsLooped(bool value) override;

	float minDistance = 5.f;
	float maxDistance = 10.f;

	bool isLooped = false;

	// the volume to play this sound in world space
	float volume = 1.f;

	SoundEffect3D(void);
public:
	// updates the sound
	virtual void Update(void) override;
	
	virtual ~SoundEffect3D(void);

	virtual void setVolume(float value) override { volume = value; }

	virtual float getVolume(void) const override { return volume; }

	virtual Vector3 getVelocity(void) const { return velocity; }

	void setVelocity(Vector3& value) { velocity = value; }

	float getMinDistance(void) const { return minDistance; }

	float getMaxDistance(void) const { return maxDistance; }

	void setMinDistance(float value) { minDistance = value; }

	void setMaxDistance(float value) { maxDistance = value; }


	/////////////////////<Accessors>//////////////////////////////////////////
	Vector3 getPosition(void) const { return position; }

	float getRange(void) const { return range; }
	/////////////////////<Mutators>//////////////////////////////////////////

	void setRange(float value) { range = value; }

	void setPosition(Vector3& value) { position = value; }
};